当前位置: 首页> 函数类别大全> date_sunset

date_sunset

返回给定日期和位置的日落时间
名称:date_sunset
分类:日期和时间
所属语言:php
一句话介绍:返回指定日期与位置的日落时间。

定义和用法

date_sunset() 函数返回指定日期与地点的日落时间。

提示:请参阅 date_sunrise() 函数,返回指定日期与地点的日出时间。

实例

返回葡萄牙里斯本今天的日落时间:

<?php
// 上海,中国:
// 维度:北纬 31.22 ,经度:西经 121.47
// 天顶 ~= 90,偏移:+8 GMT

echo("上海,中国:日期:" . date("D M d Y"));
echo("<br>日出时间:");
echo(date_sunrise(time(),SUNFUNCS_RET_STRING,31.22,121.47,90,8));
?>

亲自试一试

语法

date_sunset(timestamp,format,latitude,longitude,zenith,gmtoffset);
参数 描述
timestamp 必需。规定要计算日落时间的日期时间戳。
format

可选。规定如何返回结果:

  • SUNFUNCS_RET_STRING(以字符串返回结果,比如 16:46)(默认)
  • SUNFUNCS_RET_DOUBLE(以浮点数返回结果,比如 16.78243132)
  • SUNFUNCS_RET_TIMESTAMP(以整数(时间戳)返回结果,比如 1095034606)
latitude 可选。规定地点的纬度。默认是指北纬。如需指定南纬,请传递负值。
longitude 可选。规定地点的经度。默认是指东经。如需指定西经,请传递负值。
zenith 可选。默认为 date.sunset_zenith。
gmtoffset 可选。规定 GMT 与本地时间的差值,以小时计。
同类函数
  •  DateTime::add的别名 : 给一个 DateTime 对象增加一定量的天,月,年,小时,分钟 以及秒。 date_add

    date_add

    DateTime::add的别名:给一个
  •  解析strftime生成的时间/日期 strptime

    strptime

    解析strftime生成的时间/日期
  •  DateTimeZone::getName的别名 - 返回时区名称 timezone_name_get

    timezone_name_get

    DateTimeZone::getNam
  •  返回当前的Unix时间戳,以及微秒数 microtime

    microtime

    返回当前的Unix时间戳,以及微秒数
  •  根据区域设置格式化本地时间/日期 strftime

    strftime

    根据区域设置格式化本地时间/日期
  •  将本地时间/日期格式化为整数 idate

    idate

    将本地时间/日期格式化为整数
  •  返回给定日期和位置的日出时间 date_sunrise

    date_sunrise

    返回给定日期和位置的日出时间
  •  DateTime::__construct的别名 - 返回一个新的 DateTime 对象 date_create

    date_create

    DateTime::__construc